current_path=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
project_root=$current_path/..
bin_dir=$project_root/bin
log_dir=$project_root/log

if [ ! -d $bin_dir ];then
    mkdir -p $bin_dir
    echo "empty bin dir, no executable program"
    exit
fi

if [ ! -d $log_dir ];then
    mkdir -p $log_dir
fi

exec_file=$bin_dir/server
if [ ! -f $exec_file ];then
    echo "bin:[$exec_file] not exist"
    exit
fi

cd $project_root
ps aux | grep "$project_root" | grep -v "grep" | awk -F" " '{print $2}' | xargs -i kill -9 {}

$exec_file
cd $current_path
